Skip to content

Block Header should use waveEnv for context menu (for mocking)#3041

Merged
sawka merged 2 commits intomainfrom
sawka/blockheader-contextmenu
Mar 12, 2026
Merged

Block Header should use waveEnv for context menu (for mocking)#3041
sawka merged 2 commits intomainfrom
sawka/blockheader-contextmenu

Conversation

@sawka
Copy link
Member

@sawka sawka commented Mar 12, 2026

No description provided.

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Mar 12, 2026

Deploying waveterm with  Cloudflare Pages  Cloudflare Pages

Latest commit: 7282e08
Status: ✅  Deploy successful!
Preview URL: https://6b574de7.waveterm.pages.dev
Branch Preview URL: https://sawka-blockheader-contextmen.waveterm.pages.dev

View logs

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 12, 2026

Walkthrough

The changes refactor context menu handling across three files. A new showContextMenu property is added to the BlockEnv type. The block frame header's context menu handler is updated to accept BlockEnv as a parameter, replacing direct ContextMenuModel usage with the environment-based approach. The mock wave environment is extended with a new fullConfigAtom property and a corresponding "setconfig" RPC handler that merges settings into the configuration atom.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ❓ Inconclusive No description was provided by the author, making it impossible to assess whether it relates to the changeset. Add a pull request description explaining the purpose of refactoring to use waveEnv for context menu access and the benefits for mocking.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: refactoring the block header to use waveEnv for context menu functionality instead of directly using ContextMenuModel.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch sawka/blockheader-contextmenu

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@kilo-code-bot
Copy link
Contributor

kilo-code-bot bot commented Mar 12, 2026

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Overview

Severity Count
CRITICAL 0
WARNING 0
SUGGESTION 0

Changes Reviewed

The PR makes three related changes:

  1. frontend/app/block/blockenv.ts - Exposes showContextMenu function from WaveEnv to BlockEnv type

  2. frontend/app/block/blockframe-header.tsx - Refactors context menu handling to use injected BlockEnv.showContextMenu() instead of the ContextMenuModel.getInstance() singleton pattern

  3. frontend/preview/mock/mockwaveenv.ts - Adds mock implementation for the setconfig RPC command to support configuration updates in preview mode

All changes appear correct and follow the project's existing patterns. The refactoring moves from a static singleton to dependency injection via WaveEnv, which improves testability.

Files Reviewed (3 files)
  • frontend/app/block/blockenv.ts
  • frontend/app/block/blockframe-header.tsx
  • frontend/preview/mock/mockwaveenv.ts

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (2)
frontend/app/block/blockframe-header.tsx (1)

179-179: Minor naming inconsistency: waveEnv vs blockEnv.

BlockFrame_Header uses waveEnv (line 179) while HeaderEndIcons uses blockEnv (line 116) for the same typed value (BlockEnv). Both are correct, but consistent naming would improve readability.

♻️ Optional: Rename for consistency
-    const waveEnv = useWaveEnv<BlockEnv>();
+    const blockEnv = useWaveEnv<BlockEnv>();
     const metaView = jotai.useAtomValue(waveEnv.getBlockMetaKeyAtom(nodeModel.blockId, "view"));

(Would require updating all waveEnv references in BlockFrame_Header to blockEnv.)

Also applies to: 215-215

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@frontend/app/block/blockframe-header.tsx` at line 179, The file has
inconsistent variable naming: BlockFrame_Header uses waveEnv from
useWaveEnv<BlockEnv>() while HeaderEndIcons and other places use blockEnv;
rename the variable in BlockFrame_Header (and any other occurrences in that
component) from waveEnv to blockEnv so the type useWaveEnv<BlockEnv>() stays the
same but naming is consistent across components (update all references within
BlockFrame_Header to the new identifier).
frontend/preview/mock/mockwaveenv.ts (1)

216-228: Mock omits validation present in real handler—acceptable for testing but worth documenting.

The real SetBaseConfigValue (see pkg/wconfig/settingsconfig.go:781-817) validates config keys against SettingsType fields and checks value types before merging. This mock implementation intentionally skips those validations, which is fine for unit tests but means tests won't catch invalid config keys or type mismatches.

Consider adding a brief inline comment noting this difference for future maintainers:

📝 Suggested documentation
+    // Note: Unlike the real SetBaseConfigValue, this mock skips key/type validation.
+    // Tests using this mock won't catch invalid config keys or type mismatches.
     dispatchMap.set("setconfig", async (_client, data: SettingsType) => {
         const current = globalStore.get(wos.fullConfigAtom);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@frontend/preview/mock/mockwaveenv.ts` around lines 216 - 228, The mock
handler registered with dispatchMap.set("setconfig") merges provided data into
globalStore.get(wos.fullConfigAtom) without validating keys or types against
SettingsType; update the mock by adding a concise inline comment above the
handler that explicitly states this differs from the real SetBaseConfigValue
(pkg/wconfig/settingsconfig.go:781-817) which validates config keys and types,
and that the mock intentionally skips validation for testing purposes so
maintainers know tests won't catch invalid keys/type mismatches.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@frontend/app/block/blockframe-header.tsx`:
- Line 179: The file has inconsistent variable naming: BlockFrame_Header uses
waveEnv from useWaveEnv<BlockEnv>() while HeaderEndIcons and other places use
blockEnv; rename the variable in BlockFrame_Header (and any other occurrences in
that component) from waveEnv to blockEnv so the type useWaveEnv<BlockEnv>()
stays the same but naming is consistent across components (update all references
within BlockFrame_Header to the new identifier).

In `@frontend/preview/mock/mockwaveenv.ts`:
- Around line 216-228: The mock handler registered with
dispatchMap.set("setconfig") merges provided data into
globalStore.get(wos.fullConfigAtom) without validating keys or types against
SettingsType; update the mock by adding a concise inline comment above the
handler that explicitly states this differs from the real SetBaseConfigValue
(pkg/wconfig/settingsconfig.go:781-817) which validates config keys and types,
and that the mock intentionally skips validation for testing purposes so
maintainers know tests won't catch invalid keys/type mismatches.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 787df850-5d9a-4460-8d07-a81fad2bdd67

📥 Commits

Reviewing files that changed from the base of the PR and between 82048b6 and 7282e08.

📒 Files selected for processing (3)
  • frontend/app/block/blockenv.ts
  • frontend/app/block/blockframe-header.tsx
  • frontend/preview/mock/mockwaveenv.ts

@sawka sawka merged commit 59b8368 into main Mar 12, 2026
8 checks passed
@sawka sawka deleted the sawka/blockheader-contextmenu branch March 12, 2026 05:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant